<?php
defined('ANS') or die();

function parseArgs () {
	$argv = $_SERVER['argv'];

	array_shift($argv);
	array_shift($argv);

	$out = array();

	foreach ($argv as $arg) {
		if (substr($arg,0,2) == '--') {
			$eqPos = strpos($arg,'=');

			if ($eqPos === false) {
				$key = substr($arg,2);
				$out[$key] = isset($out[$key]) ? $out[$key] : true;
			} else {
				$key = substr($arg,2,$eqPos-2);
				$out[$key] = substr($arg,$eqPos+1);
			}
		} else if (substr($arg,0,1) == '-') {
			if (substr($arg,2,1) == '=') {
				$key = substr($arg,1,1);
				$out[$key] = substr($arg,3);
			} else {
				$chars = str_split(substr($arg,1));

				foreach ($chars as $char) {
					$key = $char;
					$out[$key] = isset($out[$key]) ? $out[$key] : true;
				}
			}
		} else {
			$out[] = $arg;
		}
	}

	return $out;
}

$argv = parseArgs();

putenv('SERVER_NAME=localhost');
putenv('DOCUMENT_ROOT='.dirname(__DIR__));
putenv('REQUEST_URI='.$argv['ru']);

$classes = array('Cache', 'Form', 'Html', 'Text_transform', 'Templates', 'Vars', 'Gettext', 'CachedFileReader', 'Datetime', 'Events', 'Css', 'Gd', 'Imagick', 'File', 'Data', 'Db', 'Search', 'Relation_x_1', 'Relation_1_1', 'Relation_x_x', 'Relation_1_x', 'Table', 'Mysql', 'Errors', 'Password', 'Gmaps', 'Id_relation', 'Email', 'Id_text', 'Enum', 'Image', 'Float', 'Integer', 'Boolean', 'Datetime', 'File', 'Text', 'Codefile', 'Id', 'Date', 'Realfile', 'Html', 'Title', 'Url', 'Sort', 'Varchar', 'Ip', 'Acl', 'Session', 'Regular', 'Module', 'Debug', 'Config');

foreach ($classes as $classes_value) {
	$$classes_value = object;

	global $$classes_value;
}

include_once (__DIR__.'/LoremIpsumGenerator.php');

$Lipsum = new LoremIpsumGenerator;
